import { getType } from '.';

/**
 * 节点日志信息
 */
export const log = (function () {
  const methods = ['info', 'warn', 'error'];
  const log = {};
  methods.forEach((key) => {
    log[key] = (...args) => {
      if (getType(args[0]) === 'Object') {
        const instance = args[0];
        args[0] = `[${instance.className}]`;
        if (instance.className !== 'Stage') args[0] += ` name: ${instance.name}, id: ${instance.id}`;
        args[0] += `\n`;
        args.push(`\n`);
        args.push(instance);
      }
      console[key](...args);
    };
  });
  return log;
})();
